home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH14 / EX14_1.ASM next >
Encoding:
Assembly Source File  |  1996-03-24  |  1.9 KB  |  104 lines

  1. ; EX14_1.asm
  2. ;
  3. ; This program runs some tests to determine how well the floating point
  4. ; arithmetic in the Standard Library compares with the floating point
  5. ; arithmetic on the 80x87.  It does this performing various operations
  6. ; using both methods and comparing the result.
  7. ;
  8. ; Of course, you must have an 80x87 FPU (or 80486 or later processor)
  9. ; in order to run this code.
  10.  
  11.  
  12.         .386
  13.         option        segment:use16
  14.  
  15.         include     stdlib.a
  16.         includelib    stdlib.lib
  17.  
  18.  
  19. dseg        segment    para public 'data'
  20.  
  21. ; Since this is an accuracy test, this code uses REAL8 values for
  22. ; all operations
  23.  
  24. slValue1    real8    1.0
  25. slSmallVal    real8    1.0e-14
  26. slResult    real8    ?
  27.  
  28. Value1        real8    1.0
  29. SmallVal    real8    1.0e-14
  30. Result        real8    ?
  31.  
  32. Buffer        byte    20 dup (0)
  33.  
  34. dseg        ends
  35.  
  36.  
  37. cseg        segment    para public 'code'
  38.         assume    cs:cseg, ds:dseg
  39.  
  40. Main        proc
  41.         mov    ax, dseg
  42.         mov    ds, ax
  43.         mov    es, ax
  44.         meminit
  45.  
  46.         finit            ;Initialize the FPU
  47.  
  48. ; Do 10,000,000 floating point additions:
  49.  
  50.  
  51.         printff
  52.         byte    "Adding 10,000,000 FP values together with the FPU",cr,lf,0
  53.  
  54.         mov    ecx, 10000000
  55. FPLoop:        fld    Value1
  56.         fld    SmallVal
  57.         fadd
  58.         fstp    Value1
  59.         dec    ecx
  60.         jnz    FPLoop
  61.  
  62.         printff
  63.         byte    "Result = %20GE\n",cr,lf,0
  64.         dword    Value1    
  65.  
  66. ; Do 10,000,000 floating point additions with the Standard Library fpadd routine:
  67.  
  68.         printff
  69.         byte    cr,lf
  70.         byte    "Adding 10,000,000 FP values together with the StdLib"
  71.         byte    cr,lf
  72.         byte    "Note: this may take a few minutes to run, don't get "
  73.         byte    "too impatient"
  74.         byte    cr,lf,0
  75.  
  76.         mov    ecx, 10000000
  77. SLLoop:        lesi    slValue1
  78.         ldfpa
  79.         lesi    slSmallVal
  80.         ldfpo
  81.         fpadd
  82.         lesi    slValue1
  83.         sdfpa
  84.         dec    ecx
  85.         jnz    SLLoop
  86.  
  87.         printff
  88.         byte    "Result = %20GE\n",cr,lf,0
  89.         dword    slValue1    
  90.  
  91. Quit:        ExitPgm            ;DOS macro to quit program.
  92. Main        endp
  93.  
  94. cseg            ends
  95.  
  96. sseg        segment    para stack 'stack'
  97. stk        db    1024 dup ("stack   ")
  98. sseg        ends
  99.  
  100. zzzzzzseg    segment    para public 'zzzzzz'
  101. LastBytes    db    16 dup (?)
  102. zzzzzzseg    ends
  103.         end    Main
  104.